package com.collect.tanzania.zhiAdater.zhiFilterPerformance;

import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.collect.tanzania.R;
import com.collect.tanzania.zhiBean.zhiReceive.ZHIRFilterEntity;

public class ZHIFilterMonthAdjuster extends BaseQuickAdapter<ZHIRFilterEntity, BaseViewHolder> {

    public ZHIFilterMonthAdjuster() {
        super(R.layout.item_filter_month_list, null);
    }

    private OnZHIFilterAdjusterItemClickListener mOnZHIFilterAdjusterItemClickListener;

    @Override
    protected void convert(BaseViewHolder helper, ZHIRFilterEntity item) {
        TextView tv_level = helper.getView(R.id.tv_title);
        tv_level.setText(item.getLevel());
        tv_level.setTextColor(item.isChecked() ? mContext.getResources().getColor(R.color.white) : mContext.getResources().getColor(R.color.theme_color_0));

        //第1行
        if(0==helper.getAdapterPosition()){
            tv_level.setBackgroundResource(item.isChecked() ? R.drawable.bg_solid_radius_left_top_theme_color0_6dp : R.drawable.bg_stroke_radius_left_right_top_bottom_6dp);
        }
        if(1==helper.getAdapterPosition()||2==helper.getAdapterPosition()){
            tv_level.setBackgroundResource(item.isChecked() ? R.drawable.bg_solid_radius_theme_color0_0dp : R.drawable.bg_stroke_radius_right_top_bottom_1dp);
        }
        if(3==helper.getAdapterPosition()){
            tv_level.setBackgroundResource(item.isChecked() ? R.drawable.bg_solid_radius_right_top_theme_color0_6dp : R.drawable.bg_stroke_radius_right_top_bottom_6dp);
        }

        //第2行
        if(4==helper.getAdapterPosition()){
            tv_level.setBackgroundResource(item.isChecked() ? R.drawable.bg_solid_radius_theme_color0_0dp : R.drawable.bg_stroke_radius_left_right_bottom_1dp);
        }
        if(5==helper.getAdapterPosition()||6==helper.getAdapterPosition()||7==helper.getAdapterPosition()){
            tv_level.setBackgroundResource(item.isChecked() ? R.drawable.bg_solid_radius_theme_color0_0dp : R.drawable.bg_stroke_radius_right_bottom_1dp);
        }

        //第3行
        if(8==helper.getAdapterPosition()){
            tv_level.setBackgroundResource(item.isChecked() ? R.drawable.bg_solid_radius_left_bottom_theme_color0_6dp : R.drawable.bg_stroke_radius_left_right_bottom_6dp);
        }
        if(9==helper.getAdapterPosition()||10==helper.getAdapterPosition()){
            tv_level.setBackgroundResource(item.isChecked() ? R.drawable.bg_solid_radius_theme_color0_0dp : R.drawable.bg_stroke_radius_right_bottom_1dp);
        }
        if(11==helper.getAdapterPosition()){
            tv_level.setBackgroundResource(item.isChecked() ? R.drawable.bg_solid_radius_right_bottom_theme_color0_6dp : R.drawable.bg_stroke_radius_right_bottom_6dp);
        }

        helper.getView(R.id.tv_title).setOnClickListener(v -> {
            if (mOnZHIFilterAdjusterItemClickListener != null) {
                mOnZHIFilterAdjusterItemClickListener.OnItemClick(item, helper.getAdapterPosition());
            }
        });
    }

    public void setOnZHIFilterAdjusterItemClickListener(OnZHIFilterAdjusterItemClickListener listener) {
        this.mOnZHIFilterAdjusterItemClickListener = listener;
    }
}
